#include "helper/object/std/StandardRawType.h"
#include <sstream>
#include <iomanip> // for setprecision

namespace helper {
namespace object {

StandardByte::StandardByte(const char value)
:value_(value)
{
}
StandardByte::~StandardByte(){
}

const char StandardByte::set(const char value){
    const char old = value;
    this->value_ = value;
    return old;
}
const char StandardByte::get() const {
    return value_;
}
std::string StandardByte::toString() const {
    std::ostringstream oss;
    oss << "StandardByte:"<< value_;
    return oss.str();
}

bool StandardByte::equals(const Object & obj) const {
    if(this != &obj){
        return obj.isByte() && (value_ == static_cast<const StandardByte&>(obj).get());
    }
    return true;
}

Object * StandardByte::copy() const {
    return new StandardByte(value_);
}


StandardInteger::StandardInteger(const long long value)
: value_(value)
{
}
StandardInteger::~StandardInteger() {
}

const long long StandardInteger::set(const long long value) {
    const long long old = value;
    this->value_ = value;
    return old;
}
const long long StandardInteger::get() const {
    return value_;
}
std::string StandardInteger::toString() const {
    std::ostringstream oss;
    oss << "StandardInteger:"<< value_;
    return oss.str();
}

Object * StandardInteger::copy() const {
    return new StandardInteger(value_);
}
bool StandardInteger::equals(const Object & obj) const {
    if(this != &obj){
        return obj.isInteger() && (value_ == static_cast<const StandardInteger&>(obj).get());
    }
    return true;
}


StandardDouble::StandardDouble(const double value)
: value_(value)
{
}
StandardDouble::~StandardDouble(){
}

const double StandardDouble::set(const double value) {
    const double old = value;
    this->value_ = value;
    return old;
}
const double StandardDouble::get() const {
    return value_;
}

std::string StandardDouble::toString() const {
    std::ostringstream oss;
    oss << "StandardDouble:" << std::fixed << std::setprecision(9) << value_;
    return oss.str();
}

Object * StandardDouble::copy() const {
    return new StandardDouble(value_);
}
bool StandardDouble::equals(const Object & obj) const {
    if(this != &obj){
        return obj.isDouble() && (value_ == static_cast<const StandardDouble&>(obj).get());
    }
    return true;
}

} // end of namespace object
} // end of namespace helper
